<?php

declare(strict_types=1);

namespace App\Controller\Client;


use App\Controller\AbstractController;
use App\Request\Client\TaskEmployer\ListRequest;
use App\Request\Client\TaskEmployer\ProcessAuditRequest;
use App\Request\Client\TaskEmployer\ProcessListRequest;
use App\Request\Client\TaskEmployer\PublishRequest;
use App\Request\Client\TaskEmployer\StatisticsRequest;
use App\Request\Client\TaskEmployer\UpdateRequest;
use App\Request\Client\TaskEmployer\UpdateShowStatusRequest;
use App\Service\Client\TaskEmployerService;
use Hyperf\Di\Annotation\Inject;

class TaskEmployerController extends AbstractController
{
    /**
     * @Inject()
     * @var TaskEmployerService
     */
    protected $taskEmployerService;


    /**
     * 任务统计
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function statistics(){
        $data = $this->taskEmployerService->statistics();
        return $this->response->success($data);
    }

    /**
     * 任务发布
     * @param PublishRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function publish(PublishRequest $request)
    {
        $validator = $request->validated();
        $data = $this->taskEmployerService->publish($validator);
        return $this->response->success($data);
    }

    /**
     * 任务列表
     * @param ListRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function list(ListRequest $request)
    {
        $validator = $request->validated();
        $data = $this->taskEmployerService->list($validator);
        return $this->response->success($data);
    }

    /**
     * 任务修改
     * @param $id
     * @param UpdateRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function update($id, UpdateRequest $request)
    {
        $validator = $request->validated();
        $data = $this->taskEmployerService->update($id, $validator);
        return $this->response->success($data);
    }

    /**
     * 任务修改-上/下架
     * @param $id
     * @param UpdateShowStatusRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function updateShowStatus($id, UpdateShowStatusRequest $request)
    {
        $validator = $request->validated();
        $this->taskEmployerService->updateShowStatus($id, $validator);
        return $this->response->success();
    }

    /**
     * 任务退款
     * @param $id
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function refund($id)
    {
        $this->taskEmployerService->refund($id);
        return $this->response->success();
    }


    /**
     * 被领取任务进度-列表
     * @param ProcessListRequest $request
     * @return mixed|\Psr\Http\Message\ResponseInterface
     */
    public function processList(ProcessListRequest $request)
    {
        $validator = $request->validated();
        $data = $this->taskEmployerService->processList($validator);
        return $this->response->success($data);
    }

    /**
     * 任务进度-审核
     * @param $id
     * @param ProcessAuditRequest $request
     * @return mixed|\Psr\Http\Message\ResponseInterface
     */
    public function processAudit($id, ProcessAuditRequest $request)
    {
        $validator = $request->validated();
        $this->taskEmployerService->processAudit($id, $validator);
        return $this->response->success();
    }


}